const router = require('koa-router')()
const apiBase = require('./apiBase');

const usersRegister = require('./../controller/users/register')
const usersLogin = require('./../controller/users/login')
const Verify = require('./../controller/users/verify')

router.prefix(apiBase + '/users')

/*
  注册接口
 */
router.post('/register', Verify.moiblePwd,  usersRegister.create)

/*
  登录接口
 */
router.post('/login', Verify.moiblePwd, usersLogin.login)

/*
  退出登录接口
 */
router.post('/logout', async function (ctx, next) {
  ctx.body = {
    msg: '退出成功',
    data: '',
    code: global.returnData.success.code
  }
})

module.exports = router
